package com.kaoshi.controller;


import com.kaoshi.common.config.Result;
import com.kaoshi.entity.Jkjl;
import com.kaoshi.service.IJkjlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-10-25
 */
@RestController
@CrossOrigin
@RequestMapping("/jkjl")
public class JkjlController {
    @Autowired
    private IJkjlService jkjlService;


    @RequestMapping("getInfo")
    public Result getInfo(Integer id){
        List<Jkjl> list=jkjlService.getInfo(id);
        if(list.size()!=0){
            System.out.println(list.get(0)+"------------");
            return Result.ok(list.get(0));
        }
        return Result.ok(null);
    }

    @RequestMapping("update")
    public Result update(@RequestBody Jkjl jkjl){
        System.out.println(jkjl);
        if(jkjl.getId()!=null){
            jkjlService.updateById(jkjl);
        }
       else{
           jkjlService.save(jkjl);
        }
        return Result.ok(jkjl);
    }
}
